package com.taotao.job.rpc.util;

import com.google.common.base.Preconditions;
import com.taotao.job.rpc.core.proxy.CglibRpcProxyFactory;
import com.taotao.job.rpc.core.proxy.RpcProxyFactory;
import com.taotao.job.rpc.core.utils.StringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;


/**
 * @author fanbeibei
 * @date 2021/4/7 22:51
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RpcClientUtil {
    private static final RpcProxyFactory proxyFactory = new CglibRpcProxyFactory();

    public static <T> T getIfaceClient(Class<T> ifaceClass, String address) {
        Preconditions.checkArgument(null != ifaceClass);
        Preconditions.checkArgument(StringUtils.isNotBlank(address));
        return proxyFactory.newProxyInstance(ifaceClass, address);
    }
}
